﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using SharePointBrowser.Properties;
using System.Drawing;

namespace SharePointBrowser
{
    public class SPListItem : SPItem
    {
        public string ListId { get; set; }
        public int ItemCount { get; set; }

        public SPListItem(XmlNode list)
            : base(list)
        {
            this.Image = Resources.ITGEN;
            this.ListId = list.Attributes["ID"].Value;
        }

        protected override string getTrimmedName(Graphics graphics)
        {
            int elipsisWidthName = (int)graphics.MeasureString(elipsis, DrawingHelper.LABEL_FONT).Width;
            string itemCountStr = " (" + ItemCount + ")";
            int itemCountWidth = (int)graphics.MeasureString(itemCountStr, DrawingHelper.LABEL_FONT).Width;
            int textMaxWidth = size.Width - (HPADDING + ImageWidth + 15 + 15) - HPADDING - elipsisWidthName - itemCountWidth - 10;
            return DrawingHelper.TrimText(Name, elipsis, textMaxWidth, graphics, DrawingHelper.LABEL_FONT) + itemCountStr;
        }
    }
}
